package sort;

import common.Print;

/**
 * 希尔排序
 */
public class ShellSort {

    public static void main(String[] args) {
        int[] arr = {3,5,2,4,15,19,25,47,26,27,2,46,4,19,48,50};
        //int[] arr = {3,2,5,1};
        sort(arr);
        Print.printArr(arr);
    }

    public static void sort(int[] arr){
        for (int i = arr.length/2; i > 0; i=i/2) {
            for (int j = 0; j+i < arr.length;j++) {
                int t = j;
                while (t+i < arr.length){
                    if(arr[t] > arr[t+i]){
                        int temp = arr[t];
                        arr[t]=arr[t+i];
                        arr[t+i]=temp;
                    }
                    t = t+i;
                }
            }
        }
    }


}
